<extend name="Public/common"/>
<block name="othercss">
    <script src="{$theme_path}/localResizeIMG/lib/mobileFix.mini.js?v=ad62f13"></script>
    <script src="{$theme_path}/localResizeIMG/lib/exif.js?v=dd609b9"></script>
    <script src="{$theme_path}/localResizeIMG/lrz.js?v=3d33fcf"></script>    
</block>
<block name="body">
<div class="mian" style="background-color: #f4f4f4">
    <div class="help">
        <div class="box">
            <div class="loc"><i class="icon iconloc"></i>您现在在这里：<a href="{:urlrotue('/')}">百宝库</a> > <a href="{:urlrotue('Member/index')}">个人中心</a> > <span class="on">账户信息</span>
            </div>
            <div class="clearfix help_list">
                <div class="right">
                    <div class="href-a">
                <a href="{:urlrotue('Member/edit')}">基本资料</a>
                        <a href="{:urlrotue('Member/headpic')}" class="on">头像照片</a>
                    </div>
                    <h2 class="title">账户信息</h2>
                    <div class="zhxx1sum">
                        <a class="btn" onclick="uploadphoto.click()"><i class="icon"></i>请选择您要上传的头像</a>
                       <div class="sm">仅支持JPG、GIF、PNG、JPEG格式，文件小于2M</div>
                        <div class="clearfix cl">
                            <div class="rights">
                                <div class="lan">您上传的头像会自动生成两种尺寸，<br>请注意小尺寸的图像是否清晰</div>
                                 <input type="hidden" value="{$headpic}" name="headpic" id="headpic" />
                                <div class="imgs"><img src="__ROOT__{$headpic}" onerror='this.src="{$theme_path}/images/header.jpg"' onclick="uploadphoto.click()"  id="img_path2" width="100" height="100"></div>100*100像素
                               
                            </div>
                            <div class="lefts">
                                <div class="pic"><img id="img_path" src="{$theme_path}/images/tou.png" width="350" height="350" /></div>
                            </div>
                        </div>
                         <input type="file" id="uploadphoto" name="uploadfile" value="请点击上传图片"   style="display:none;" /> 
                        <input type="submit"  style="display:none" class="sub" value="保存"/>
                    </div>
                </div>
                    <include file="Member:left_menu"/>
            </div>
        </div>
    </div>
</div>
</block>
<block name="otherjs">
                     
<script type="text/javascript">
        //var pic_index = $("#pic_index").val();
        $(document).ready(function (e) {
            //单图上传
           // var pic_index = $("#pic_index").val();
			
            var uploadphoto = document.getElementById('uploadphoto');
			
            uploadphoto.onchange = function () {
				
               // pic_index++;
               // var pic_index2 = pic_index;
               // var attstr = '<div class="htumb-list fl" id="pic' + pic_index2 + '"><img id="picimg' + pic_index2 + '" src="../Public/images/loading.gif"  onclick="editpic(' + pic_index2 + ')"></div>';
               // $("#piclist").append(attstr);
                lrz(this.files[0], {width: 350,height:350}, function (results) {
                    // 你需要的数据都在这里，可以以字符串的形式传送base64给服务端转存为图片。
                    //console.log(results);
                    // 发送到后端
                    var xhr = new XMLHttpRequest();
                    var data = {
                        base64: results.base64,
                        size: results.base64.length // 校验用，防止未完整接收
                    };
                    xhr.open('POST', "{:urlrotue('Member/upload')}");
					
                    xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
                    xhr.onreadystatechange = function () {
                        if (xhr.readyState === 4 && xhr.status === 200) {
                            var result = JSON.parse(xhr.response);
                           // console.log(result);
                            if (result.error == 2) {
                                alert('你的图片格式为' + result.msg + ',只支持JPG\GIF\PNG图片！');
                               // $("#pic" + pic_index2).remove();
                            } else if (result.error == 1) {
                                alert('图片上传出错，请拍照或重试'+result.msg);
                               // $("#pic" + pic_index2).remove();
                            } else {
                                $("#img_path2").attr('src', '__ROOT__' + result.src+'?v='+ (new Date()).getTime());
								$("#img_path").attr('src', '__ROOT__' + result.src+'?v='+ (new Date()).getTime());
                                //var detail_pic = $("#detail_pic").val();
								 $("#left_headpic").attr('src', '__ROOT__' + result.src+'?v='+ (new Date()).getTime());
								
                                $("#headpic").val(result.src2);
                                //console.log(detail_pic + result.src + ",");
                            }
                        }
                    };
                    xhr.send(JSON.stringify(data)); // 发送base64
                });
            };
			});
			</script>

</block>
